<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.css" rel="stylesheet" />
		<style>
			
			.mui-bar{
				position: fixed;
				background-color: #000000;
				box-shadow: none;
			}
			.title-color,#chatting-nickname{
				color: #FFFFFF;
			}
			#scanComponent {
				width: 100%;
				bottom: 0px;
				position: absolute;
				text-align: center;
				background: #000000;
			}
			
		</style>
	</head>

	<body >

		<header class="mui-bar mui-bar-nav" id="header">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left title-color"></a>
			<h1 class="mui-title title-color"><b id="chatting-nickname">扫一扫</b></h1>
		</header>
		
		<div class="mui-content">
		    <div id="scanComponent"></div>
		</div>		
		
		<script type="text/javascript" src="../js/mui.min.js"></script>
		<script type="application/javascript" src="../js/app.js"></script>
		<script src="../js/immersed.js"></script>
		<script type="text/javascript">
			mui.init();
			
			mui.plusReady(function(){
				
				starbar();
				document.getElementById('scanComponent').style.top = (immersed + 44) + "px";
				
				setTimeout("startScan()", "500");
				
			});
			
			var scan;
			function startScan() {
				
				var styles = {
					frameColor: "#0A7FFF",
					scanbarColor: "0A7FFF",
					background: ""
				}
				
				scan = new plus.barcode.Barcode('scanComponent', null, styles);
				scan.onmarked = onmarked; 
				scan.start();
			}
			
			function onmarked( type, result ) {
				if (type === 0) {
					var content = result.split("lunyu_qrcode:");
					if (content.length != 2) {
						mui.alert(result)
					} else {
						var lyfriend_Card = content[1];
						var user = app.getUserGlobalInfo();
						var lyuser_Card = user.lyuser_Card;
						plus.nativeUI.showWaiting("请稍后...");

						mui.ajax({
							url: app.serverUrl + '/friendListController/sreachFriend',
							data: {
								lyfriend_Card: lyfriend_Card,
								lyuser_Card: lyuser_Card
							},
							async: true, //将false改为true
							crossDomain: true, //强制使用5+跨域
							dataType: 'json', //服务器返回json格式数据
							type: 'get', //HTTP请求类型
							timeout: 10000, //超时时间设置为10秒；
							//processData: false,
							headers: {
								'Content-Type': 'application/x-www-form-urlencoded'
							},
							success: function(data) {
								mui.openWindow({
									url: "goodfriend/SMTzhuan.html",
									id: "goodfriend/SMTzhuan.html",
									extras: {
										data: data,
										ta_card: lyfriend_Card
									}
								})
							},
							error: function(xhr, type, errorThrown) {
								//异常处理；
								mui.alert("失败了！");
							}
						})
					}
				}
				scan.start();
			}
		</script>
	</body>

</html>